package com.zbs.simbot.plugins.example;

import cn.hutool.core.util.IdUtil;
import com.zbs.simbot.annotations.Func;
import com.zbs.simbot.factory.BasePlugin;
import com.zbs.simbot.factory.abstracts.AbstractsBasePlugin;
import com.zbs.simbot.factory.dto.PluginInfo;
import com.zbs.simbot.enums.MsgType;
import com.zbs.simbot.enums.QQListType;
import com.zbs.simbot.events.BaseMsgEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Arrays;

@Component
@Slf4j
public class DefaultBasePlugin extends AbstractsBasePlugin {

    @Override
    public String getId() {
        return IdUtil.getSnowflakeNextIdStr();
    }

    @Override
    public PluginInfo getInfo() {
        return new PluginInfo("recv from","打印消息");
    }


    @Func(ignoreReg = true,msgType = MsgType.PRIVATE_AND_FRIEND)
    public void friendMsg(BaseMsgEvent event) {
        PluginInfo info = this.getInfo();
        log.info("[{}]: [{}: {}({})] {}",event.getMsgType(),info.getName(),event.getUser().getUsername(),event.getUserId(),event.getFullMsg());
    }

    @Func(ignoreReg = true,msgType = MsgType.GROUP)
    public void groupMsg(BaseMsgEvent event) {
        PluginInfo info = this.getInfo();
        log.info("[{}]: [{}: {}({}),{}({})] {}",event.getMsgType(),info.getName(),event.getGroup().getName(),event.getGroup().getId(),event.getUser().getUsername(),event.getUserId(),event.getFullMsg());
    }
}
